#include "Mesh.h"

namespace steam
{
	namespace coal
	{
		const VertexVector& Mesh::getVertices() const
		{
			return m_vertices;
		}

		const NormalVector& Mesh::getNormals() const
		{
			return m_normals;
		}

		const TexCoordVector& Mesh::getTexCoords() const
		{
			return m_texcoords;
		}

		unsigned int Mesh::getMeshBufferCount() const
		{
			return m_meshBuffers.size();
		}

		const IMeshBuffer* Mesh::getMeshBuffer( unsigned int index ) const
		{
			return m_meshBuffers[index];
		}

		std::string Mesh::getMeshName() const
		{
			return m_name;
		}

		const base::IBoundingVolume* Mesh::getBoundingVolume() const
		{
			return NULL;
		}

		void Mesh::addMeshBuffer(IMeshBuffer* meshBuffer)
		{
			m_meshBuffers.push_back(meshBuffer);
		}

		void Mesh::addVertex( const Vertex& vertex )
		{
			m_vertices.push_back(vertex);
		}

		void Mesh::addNormal( const Normal& normal )
		{
			m_normals.push_back(normal);
		}

		void Mesh::addTexCoord( const TexCoord& texcoord )
		{
			m_texcoords.push_back(texcoord);
		}

		void Mesh::setMeshName(const char* name)
		{
			m_name = name;
		}

		const IMaterial* Mesh::getMaterialByName(std::string name) const
		{
			for (std::vector<IMaterial*>::const_iterator it = m_materials.begin(); it != m_materials.end(); ++it)
			{
				const IMaterial* material = *it;
				if (material && material->getMaterialName() == name)
				{
					return material;
				}
			}
			return NULL;
		}

		void Mesh::addMaterial( IMaterial* material )
		{
			m_materials.push_back(material);
		}

		const MaterialVector& Mesh::getMaterials() const
		{
			return m_materials;
		}

	}

}
